package com.zsc.oj.config;

import com.zhipu.oapi.ClientV4;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 智谱api模型客户端连接配置
 */
@Configuration
@ConfigurationProperties(prefix = "ai")
@Data
public class ApiConfig {

    /**
     * 获取到yml文件的apiKey
     */
    private String apiKey;

    /**
     * 标注为一个实体bean，就不需要自行创建，用@Resource引入即可
     * @return
     */
    @Bean
    public ClientV4 getClient(){
        return new ClientV4.Builder(apiKey).build();
    }
}
